package com.bjsxt.mapper;

import com.bjsxt.pojo.Menu;
import com.bjsxt.pojo.TreeA;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface MenuMapper {

    @Select("SELECT * FROM t_menu WHERE mid in (SELECT mid FROM t_role_menu WHERE rid in(SELECT rid FROM t_admin_role WHERE aid=#{param1})) and pid=#{param2}")
    List<Menu> selectMenu(Integer aid,Integer pid);

    //查询
    @Select("select * from t_menu")
    List<Menu> selectPagMenu();

    //查询所有表单
    @Select("select * from t_menu where pid=#{param1}")
    List<Menu> selectMenu2(Integer pid);

    //添加菜单实现
    @Insert("insert into t_menu(mname,pid,status,url,mdesc) values(#{mname},#{pid},#{status},#{url},#{mdesc})")
    Integer insertMenu(Menu menu);

    //修改菜单表
    @Update("update t_menu set mname=#{mname},pid=#{pid},status=#{status},url=#{url},mdesc=#{mdesc} where mid=#{mid}")
    Integer updateMenu(Menu menu);

    //删除菜单
    @Delete("delete from t_menu where mid=#{param1}")
    Integer deleteMenu(Integer mid);

    //同部树查询

    List<TreeA> selectMenu3(Integer pid);
}
